import requests
import json
import readExcel
import unittest
import readConfig
import test_login
import test_status
import test_backscanning


class test_Refund_Query(unittest.TestCase):
    def setUp(self):
        self.url, self.data, self.headers = readExcel.read_Excel().read_excel(
            20)  # 根据excel用用例的函数，从0开始提交行数即可，case001就填写1
        self.sn = readConfig.readConfig('data', 'sn')
        self.token = test_status.test_Status().test_status()[0]
        self.auth_token = test_login.test_Login().test_login('shop')
        self.order_no = test_backscanning.test_Backscanning().test_backscanning()[0]

    def test_refund_query(self):
        self.data['sn'] = self.sn
        self.data['token'] = self.token
        self.data['order_no'] = self.order_no
        self.data['auth_token'] = self.auth_token
        # print(self.id)
        # 开始提交参数到接口
        # print(self.data)
        r1 = requests.post(self.url, data=self.data, headers=self.headers)
        r2 = r1.json()
        print(json.dumps(r2, sort_keys=True, indent=4, separators=(',', ':'), ensure_ascii=False))
        self.assertEqual(r2['code'], 0)

    def tearDown(self):
        pass


if __name__ == '__main__':
    unittest.main()
